package org.michaelrenaud.pathfinder.shared.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class StatBlock implements Serializable {

	private static final long serialVersionUID = 8125073880474926612L;
	
	private Stat sizeModifier;
	
	// Ability Score
	private Stat strength;
	private Stat dexterity;
	private Stat constitution;
	private Stat intelligence;
	private Stat wisdom;
	private Stat charisma;
	
	// Item Bonus
	private int strengthItemBonus;
	private int dexterityItemBonus;
	private int constitutionItemBonus;
	private int intelligenceItemBonus;
	private int wisdomItemBonus;
	private int charismaItemBonus;
	
	// Init
	private int init;
	private Stat initFeat;
	private Stat initTraining;
	private Stat initMisc;
	
	// Speeds
	private int baseSpeed;
	private int flySpeed;
	private int swimSpeed;
	private int climbSpeed;
	private int mountSpeed;
	
	private List<StatBlockSkill> skills = new ArrayList<StatBlockSkill>();


	public StatBlock() {}

	public Stat getStrength() {
		return strength;
	}

	public void setStrength(Stat strength) {
		this.strength = strength;
	}

	public Stat getDexterity() {
		return dexterity;
	}

	public void setDexterity(Stat dexterity) {
		this.dexterity = dexterity;
	}

	public Stat getConstitution() {
		return constitution;
	}

	public void setConstitution(Stat constitution) {
		this.constitution = constitution;
	}

	public Stat getIntelligence() {
		return intelligence;
	}

	public void setIntelligence(Stat intelligence) {
		this.intelligence = intelligence;
	}

	public Stat getWisdom() {
		return wisdom;
	}

	public void setWisdom(Stat wisdom) {
		this.wisdom = wisdom;
	}

	public Stat getCharisma() {
		return charisma;
	}

	public void setCharisma(Stat charisma) {
		this.charisma = charisma;
	}

	public int getStrengthItemBonus() {
		return strengthItemBonus;
	}

	public void setStrengthItemBonus(int strengthItemBonus) {
		this.strengthItemBonus = strengthItemBonus;
	}

	public int getDexterityItemBonus() {
		return dexterityItemBonus;
	}

	public void setDexterityItemBonus(int dexterityItemBonus) {
		this.dexterityItemBonus = dexterityItemBonus;
	}

	public int getConstitutionItemBonus() {
		return constitutionItemBonus;
	}

	public void setConstitutionItemBonus(int constitutionItemBonus) {
		this.constitutionItemBonus = constitutionItemBonus;
	}

	public int getIntelligenceItemBonus() {
		return intelligenceItemBonus;
	}

	public void setIntelligenceItemBonus(int intelligenceItemBonus) {
		this.intelligenceItemBonus = intelligenceItemBonus;
	}

	public int getWisdomItemBonus() {
		return wisdomItemBonus;
	}

	public void setWisdomItemBonus(int wisdomItemBonus) {
		this.wisdomItemBonus = wisdomItemBonus;
	}

	public int getCharismaItemBonus() {
		return charismaItemBonus;
	}

	public void setCharismaItemBonus(int charismaItemBonus) {
		this.charismaItemBonus = charismaItemBonus;
	}

	public int getSTR() {
		int modifier = (strength.getTotal() + strengthItemBonus - 10) / 2;
		return modifier;
	}

	public int getDEX() {
		int modifier = (dexterity.getTotal() + dexterityItemBonus - 10) / 2;
		return modifier;
	}

	public int getCON() {
		int modifier = (constitution.getTotal() + constitutionItemBonus - 10) / 2;
		return modifier;
	}

	public int getINT() {
		int modifier = (intelligence.getTotal() + intelligenceItemBonus - 10) / 2;
		return modifier;
	}

	public int getWIS() {
		int modifier = (wisdom.getTotal() + wisdomItemBonus - 10) / 2;
		return modifier;
	}

	public int getCHA() {
		int modifier = (charisma.getTotal() + charismaItemBonus - 10) / 2;
		return modifier;
	}

	public Stat getSizeModifier() {
		return sizeModifier;
	}

	public void setSizeModifier(Stat sizeModifier) {
		this.sizeModifier = sizeModifier;
	}

	public List<StatBlockSkill> getSkills() {
		return skills;
	}

	public void setSkills(List<StatBlockSkill> skills) {
		this.skills = skills;
	}
	
	public int getBaseSpeed() {
		return baseSpeed;
	}

	public void setBaseSpeed(int baseSpeed) {
		this.baseSpeed = baseSpeed;
	}
	

	
	public String getSizeText() {
		switch(getSizeModifier().getTotal()) {
			case 8: return "Fine";
			case 4: return "Diminutive";
			case 2: return "Tiny";
			case 1: return "Small";
			case 0: return "Medium";
			case -1: return "Large";
			case -2: return "Huge";
			case -4: return "Gargantuan";
			case -8: return "Colossal";
		}
		return "Unknown";
	}
	
	public int getModifier(String modifier) {
		if(modifier.equals("STR"))
			return getSTR();
		else if(modifier.equals("DEX"))
			return getDEX();
		else if(modifier.equals("CON"))
			return getCON();
		else if(modifier.equals("INT"))
			return getINT();
		else if(modifier.equals("WIS"))
			return getWIS();
		else if(modifier.equals("CHA"))
			return getCHA();
		return 0;
	}

	public int getFlySpeed() {
		return flySpeed;
	}

	public void setFlySpeed(int flySpeed) {
		this.flySpeed = flySpeed;
	}

	public int getSwimSpeed() {
		return swimSpeed;
	}

	public void setSwimSpeed(int swimSpeed) {
		this.swimSpeed = swimSpeed;
	}

	public int getClimbSpeed() {
		return climbSpeed;
	}

	public void setClimbSpeed(int climbSpeed) {
		this.climbSpeed = climbSpeed;
	}

	public int getMountSpeed() {
		return mountSpeed;
	}

	public void setMountSpeed(int mountSpeed) {
		this.mountSpeed = mountSpeed;
	}

	public int getInit() {
		return init;
	}

	public void setInit(int init) {
		this.init = init;
	}

	public Stat getInitFeat() {
		return initFeat;
	}

	public void setInitFeat(Stat initFeat) {
		this.initFeat = initFeat;
	}

	public Stat getInitTraining() {
		return initTraining;
	}

	public void setInitTraining(Stat initTraining) {
		this.initTraining = initTraining;
	}

	public Stat getInitMisc() {
		return initMisc;
	}

	public void setInitMisc(Stat initMisc) {
		this.initMisc = initMisc;
	}
}
